<?php

	session_start();
	require("connect.php");
	$link = connect_APO();
	
	$userID = $_SESSION['ID'];
	$postID = $_POST['userID'];
	
	if($postID != null){
		$userID = $postID;
	}
	require("check.php");
	is_logged_in();
	
	require("header+logoutB.php");
	headerL();
	
	$midweekName=$_GET['midweek_name'];
	
	$sql="DELETE FROM `$midweekName` WHERE ID='$userID'";
	
	if(!mysql_query($sql)){
		die('Error: ' .mysql_error());
	}
	
	echo "<html>
	<link rel='stylesheet' type='text/css' href='webstyle.css' />
	<head>
		<title>Removed from Midweek</title>
		<meta http-equiv='refresh' content='2; URL=index.php'>
	</head>
	<body>
	<center>
	<font class='mainFont'>"; if($postID == $userID){
			echo $userID." has ";
		}else {
			echo "You have ";
		}
		echo "been removed from the midweek. You will be redirected back to the calendar in 2 seconds.</font>
	</center>
	</body>
	</html>";
	
		require("footer.php");
	footer();
	mysql_close($link);
?>